import Message from './my-message.vue'
import { createVNode, render } from 'vue'

const div = document.createElement('div')
div.setAttribute('class', 'message-container')
document.body.appendChild(div)

let timer = null

export default ({type, message}) => {
  const vnode = createVNode(Message,{type,message})
  // 渲染DOM节点
  render(vnode, div)
  // 5. 开启定时，移出DOM容器内容
  clearTimeout(timer)
  timer = setTimeout(() => {
    render(null, div)
  }, 3000)
}